package com.example.springboot004extensionpoint.beanFactoryPostProcessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

@Component
public class KoalaBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        // BeanFactoryPostProcessor 用于修改beanFactory的属性值
        // beanfactory里面有BeanDefinition，可以修改BeanDefinition里面的值。
        // BeanDefinition是一个bean的元数据的信息，有多少个bean就有多少个BeanDefinition。
        beanFactory.getBeanDefinition("person").setAutowireCandidate(true);
        System.out.println("Koala de KoalaBeanFactoryPostProcessor");
    }
}
